namespace SharpTalk.Core.Services.Extensions
{
    using System;

    public static class ExtensionMethods
    {
        /// <summary>
        /// Checks if a request is valid using a defined condition
        /// </summary>
        /// <typeparam name="T">The type of the request</typeparam>
        /// <param name="request">The request to check</param>
        /// <param name="condition">The condition to use</param>
        /// <returns>The condition result</returns>
        public static bool IsValid<T>(this RequestBase<T> request, Func<bool> condition)
             where T : class
        {
            return condition();
        }
        /// <summary>
        /// Checks if a request is valid
        /// </summary>
        /// <typeparam name="T">The type of the request</typeparam>
        /// <param name="request">The request to check</param>
        /// <returns>True if valid otherwise False</returns>
        public static bool IsValid<T>(this RequestBase<T> request)
            where T : class
        {
            return request != null && request.Content != null;
        }
    }
}